import formmatDate from '.././DdFormmatDate/index.ts';
export default {
  // 主要日志 带时间的
  primary(title: string = '', log: any = '', isTime: boolean = true) {
    if (typeof log === 'object') {
      log = JSON.stringify(log);
    }
    let dateTime = formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    if (!isTime) {
      dateTime = '';
    } else {
      dateTime = ' ' + dateTime + ' ';
    }
    console.log(
      '%c' + title + dateTime + '%c' + log,
      'background: #606266; color: #fff; border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding:0 5px',
      'background: #409EFF; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px'
    );
  },

  // 成功日志 带时间的
  success(title: string = '', log: any = '', isTime: boolean = true) {
    if (typeof log === 'object') {
      log = JSON.stringify(log);
    }
    let dateTime = formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    if (!isTime) {
      dateTime = '';
    } else {
      dateTime = ' ' + dateTime + ' ';
    }
    console.log(
      '%c' + title + dateTime + '%c' + log,
      'background: #606266; color: #fff; border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding:0 5px',
      'background: #67C23A; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px'
    );
  },

  // 警告日志 带时间的
  warning(title: string = '', log: any = '', isTime: boolean = true) {
    if (typeof log === 'object') {
      log = JSON.stringify(log);
    }
    let dateTime = formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    if (!isTime) {
      dateTime = '';
    } else {
      dateTime = ' ' + dateTime + ' ';
    }
    console.log(
      '%c' + title + dateTime + '%c' + log,
      'background: #606266; color: #fff; border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding:0 5px',
      'background: #E6A23C; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px'
    );
  },

  // 警告日志 带时间的
  danger(title: string = '', log: any = '', isTime: boolean = true) {
    if (typeof log === 'object') {
      log = JSON.stringify(log);
    }
    let dateTime = formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    if (!isTime) {
      dateTime = '';
    } else {
      dateTime = ' ' + dateTime + ' ';
    }
    console.log(
      '%c' + title + dateTime + '%c' + log,
      'background: #606266; color: #fff; border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding:0 5px',
      'background: #F56C6C; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px'
    );
  },

  info(title: string = '', log: any = '', isTime: boolean = true) {
    if (typeof log === 'object') {
      log = JSON.stringify(log);
    }
    let dateTime = formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    if (!isTime) {
      dateTime = '';
    } else {
      dateTime = ' ' + dateTime + ' ';
    }
    console.log(
      '%c' + title + dateTime + '%c' + log,
      'background: #606266; color: #fff; border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding:0 5px',
      'background: #909399; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px'
    );
  },
  // --------只有内容没有标题------
  // 主要日志 带时间的  contentPrimary
  cp( log: any = '', isTime: boolean = false) {
    if (typeof log === 'object') {
      log = JSON.stringify(log);
    }
    let dateTime = formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    let cStyle = '';
    if (!isTime) {
      dateTime = '';
      cStyle =
        'background: #409EFF; color: #fff; border-radius: 3px; padding:0 5px';
    } else {
      dateTime = ' ' + dateTime + ' ';
      cStyle =
        'background: #409EFF; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px';
    }
    console.log(
      '%c' + dateTime + '%c' + log,
      'background: #606266; color: #fff; border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding:0 5px',
      cStyle
    );
  },

  // 成功日志 带时间的 contentsuccess
  cs(log: any = '', isTime: boolean = false) {
    if (typeof log === 'object') {
      log = JSON.stringify(log);
    }
    let dateTime = formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    let cStyle = '';
    if (!isTime) {
      dateTime = '';
      cStyle =
        'background: #67C23A; color: #fff; border-radius: 3px; padding:0 5px';
    } else {
      dateTime = ' ' + dateTime + ' ';
      cStyle =
        'background: #67C23A; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px';
    }
    console.log(
      '%c' + dateTime + '%c' + log,
      'background: #606266; color: #fff; border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding:0 5px',
      cStyle
    );
  },

  // 警告日志 带时间的 contentwarning
  cw(log: any = '', isTime: boolean = false) {
    if (typeof log === 'object') {
      log = JSON.stringify(log);
    }
    let dateTime = formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    let cStyle = '';
    if (!isTime) {
      dateTime = '';
      cStyle =
        'background: #E6A23C; color: #fff;  border-radius: 3px; padding:0 5px';
    } else {
      dateTime = ' ' + dateTime + ' ';
      cStyle =
        'background: #E6A23C; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px';
    }
    console.log(
      '%c' + dateTime + '%c' + log,
      'background: #606266; color: #fff; border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding:0 5px',
      cStyle
    );
  },

  // 警告日志 带时间的 contentdanger
  cd(log: any = '', isTime: boolean = false) {
    if (typeof log === 'object') {
      log = JSON.stringify(log);
    }
    let dateTime = formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    let cStyle = '';
    if (!isTime) {
      dateTime = '';
      cStyle =
        'background: #F56C6C; color: #fff; border-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px';
    } else {
      dateTime = ' ' + dateTime + ' ';
      cStyle =
        'background: #F56C6C; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px';
    }
    console.log(
      '%c' + dateTime + '%c' + log,
      'background: #606266; color: #fff; border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding:0 5px',
      cStyle
    );
  },

  // contentinfo
  ci(log: any = '', isTime: boolean = false) {
    if (typeof log === 'object') {
      log = JSON.stringify(log);
    }
    let dateTime = formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    let cStyle = '';
    if (!isTime) {
      dateTime = '';
      cStyle =
        'background: #909399; color: #fff; border-radius: 3px; padding:0 5px';
    } else {
      dateTime = ' ' + dateTime + ' ';
      cStyle =
        'background: #909399; color: #fff; border-top-right-radius: 3px; border-bottom-right-radius: 3px; padding:0 5px';
    }
    console.log(
      '%c' + dateTime + '%c' + log,
      'background: #606266; color: #fff; border-top-left-radius: 3px; border-bottom-left-radius: 3px; padding:0 5px',
      cStyle
    );
  }
};
